<template>
  <view class="practice-container">
    <view class="grade-bar">
      <picker :range="grades" :value="gradeIndex" @change="onGradeChange">
        <view class="grade-select">当前年级：{{ grades[gradeIndex] }} <text class="arrow">▼</text></view>
      </picker>
    </view>
    <view class="title">选择科目开始练习</view>
    <view class="subject-list">
      <view class="subject-item" v-for="subject in subjectsByGrade" :key="subject" @tap="chooseSubject(subject)">
        <text>{{ subject }}</text>
      </view>
    </view>
  </view>
</template>
<script setup>
import { ref, computed } from 'vue'
const grades = ref(['小学', '初中', '高中'])
const gradeIndex = ref(0)
const subjectMap = {
  '小学': ['语文', '数学', '英语'],
  '初中': ['语文', '数学', '英语', '物理', '化学'],
  '高中': ['语文', '数学', '英语', '物理', '化学', '生物', '历史', '地理']
}
const subjectsByGrade = computed(() => subjectMap[grades.value[gradeIndex.value]])
function onGradeChange(e) {
  gradeIndex.value = e.detail.value
}
function chooseSubject(subject) {
  uni.showToast({ title: subject + '练习题开发中', icon: 'none' })
}
</script>
<style scoped>
.practice-container { padding: 40rpx; }
.grade-bar { display: flex; justify-content: center; margin-bottom: 24rpx; }
.grade-select { background: #fff; border-radius: 16rpx; padding: 16rpx 32rpx; font-size: 28rpx; color: #07c160; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03); display: flex; align-items: center; }
.arrow { font-size: 24rpx; color: #888; margin-left: 8rpx; }
.title { font-size: 40rpx; font-weight: bold; margin-bottom: 32rpx; text-align: center; }
.subject-list { display: flex; flex-wrap: wrap; gap: 24rpx; justify-content: center; }
.subject-item { background: #eaf6ff; border-radius: 16rpx; padding: 32rpx 48rpx; font-size: 32rpx; color: #07c160; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03); margin-bottom: 16rpx; }
</style> 